package com.gdkj.util;

import com.gdkj.entity.RoomTypeConfig;
import com.gdkj.entity.UsersLive;
import com.gdkj.enums.RoomTypeEnums;
import com.gdkj.vo.RoomDataVO;

import java.util.List;

public class VOHelper {

    /**
     * 设置房间信息
     * @param usersLive
     * @return RoomDataVO
     */
    public static RoomDataVO buildRoomDataVO(UsersLive usersLive) {
        RoomDataVO roomDataVO = new RoomDataVO();
        roomDataVO.setChatRoomId(usersLive.getChatRoomId());
        roomDataVO.setRoomNumber(usersLive.getShowId());
        roomDataVO.setThumb(usersLive.getThumb()); //房间封面图
        roomDataVO.setLiveUid(usersLive.getUid());
        roomDataVO.setBgUrl(usersLive.getBgUrl());
        roomDataVO.setBgId(usersLive.getBgId());
        roomDataVO.setTitle(usersLive.getTitle());
        roomDataVO.setRoomTheme(Integer.parseInt(usersLive.getTypeVal()));
        roomDataVO.setRoomType(usersLive.getType());
        roomDataVO.setPushUrl(usersLive.getPush());
        roomDataVO.setStreamId(usersLive.getStream());
        return roomDataVO;
    }

    /**
     * 设置房间其他基本信息
     * @param roomDataVO
     * @param resultDataList
     * @param roomType
     */
    public static void setRoomDataBaseInfo(RoomDataVO roomDataVO, List<RoomTypeConfig> resultDataList, Integer roomType) {
        if (RoomTypeEnums.GO_BANG_SMART.getType().equals(roomType)) {
            roomType = RoomTypeEnums.GoBang.getType();
        }
        for (RoomTypeConfig roomTypeConfig : resultDataList) {
            if (roomType.equals(roomTypeConfig.getRoomType())) {
                roomDataVO.setRoomIcon(roomTypeConfig.getRoomIcon());
                break;
            }
        }
    }

    /**
     * 矫正房间类型
     * @param roomType
     * @return java.lang.Integer
     */
    public static Integer correctRoomType(Integer roomType) {
        // 五子棋
        if (RoomTypeEnums.GO_BANG_SMART.getType().equals(roomType)) {
            roomType = RoomTypeEnums.GoBang.getType();
        } else if (RoomTypeEnums.FLY_CHECKERS_MANNY.getType().equals(roomType) || RoomTypeEnums.FLY_CHECKERS_FOUR.getType().equals(roomType) || RoomTypeEnums.FLY_CHECKERS_SMART.getType().equals(roomType)) {
            // 飞行棋
            roomType = RoomTypeEnums.FLY_CHECKERS_TWO.getType();
        }

        return roomType;
    }
}
